package DP;

/**
 * @author 曹见朋
 * @create 2024-06-11-23:30
 */
public class Main343 {
    // TODO 343. 整数拆分
    public static int integerBreak(int n) {
        int[] dp = new int[n + 1];
        dp[0] = 0;
        dp[1] = 0;
        dp[2] = 1;
        for(int i = 3; i <= n; i++){
            int max = 0;
            for(int j = 1; j < i; j++){
                max = Math.max(max, Math.max(j * dp[i - j], j * (i - j)));
            }
            dp[i] = max;
        }

        for(int i = 0; i <= n; i++){
            System.out.print(" " + dp[i]);
        }
        return dp[n];
    }

    public static void main(String[] args) {
        int n = 10;
        int result = integerBreak(n);
        System.out.println();
        System.out.println(result);
    }
}
